home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWXDRostream.z / RWXDRostream
Encoding:
Text File  |  1998-10-30  |  16.4 KB  |  397 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                          RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWXDRostream (Unix only) - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/xdrstrea.h>
  13.  
  14.  
  15.  
  16.  
  17.           XDR xdr;
  18.           xdrstdio_create(&xdr, stdout, XDR_ENCODE) ;
  19.           RWXDRostream rw_xdr(&xdr);
  20.  
  21.  
  22.  
  23.  
  24. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  25.      Class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm is a portable output stream based on XDR routines.
  26.      Class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm encapsulates a portion of the XDR library routines
  27.      that are used for external data representation.  XDR routines allow
  28.      programmers to describe arbitrary data structures in a machine-
  29.      independent fashion.  Data for remote procedure calls (RPC) are
  30.      transmitted using XDR routines.  Class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm enables one to output
  31.      from a stream and encode an XDR structure from a machine representation.
  32.      Class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm provides the capability to encode the standard data
  33.      types and vectors of those data types.  An XDR stream must first be
  34.      created by calling the appropriate creation routine. XDR streams
  35.      currently exist for encoding/decoding of data to or from standard
  36.      iostreams and file streams, TCP/IP connections and Unix files, and
  37.      memory. These creation routines take arguments that are tailored to the
  38.      specific properties of the stream.  After the XDR stream has been
  39.      created, it can then be used as an argument to the constructor for a
  40.      RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm object.  RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm can be interrogated as to the status
  41.      of the stream using member functions bbbbaaaadddd(((()))), cccclllleeeeaaaarrrr(((()))), eeeeooooffff(((()))), ffffaaaaiiiillll(((()))),
  42.      ggggoooooooodddd(((()))), and rrrrddddssssttttaaaatttteeee(((()))).
  43.  
  44. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  45.      None
  46.  
  47. EEEExxxxaaaammmmpppplllleeee
  48.      The example that follows is a "writer" program that encodes an XDR
  49.      structure onto a file stream.  The example for class RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm is the
  50.      "reader" program that decodes the XDR structures into a machine
  51.      representation for a data type. The library that supports XDR routines
  52.      must be linked in.  The name of this library is not standard.
  53.  
  54.               #include <rw/xdrstrea.h>
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                          RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               #include <rw/rstream.h>
  75.           #include <stdio.h>
  76.           main(){
  77.            XDR xdr;
  78.            FILE* fp = fopen("test","w+");
  79.            xdrstdio_create(&xdr, fp, XDR_ENCODE);
  80.            RWXDRostream rw_xdr(&xdr);
  81.            for(int i=0; i<10; ++i)
  82.            rw_xdr << i;                       // encode integer data
  83.            fclose(fp);
  84.           }
  85.  
  86. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr
  87.               RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm(XDR* xp);
  88.  
  89.  
  90.      Initialize a RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm from the XDR structure xxxxpppp.
  91.  
  92.               RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm(streambuf*);
  93.  
  94.  
  95.      Initialize RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm with a pointer to ssssttttrrrreeeeaaaammmmbbbbuuuuffff. ssssttttrrrreeeeaaaammmmbbbbuuuuffff must
  96.      already be allocated.
  97.  
  98.               RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm(ostream&);
  99.  
  100.  
  101.      Initialize RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm with an output stream.
  102.  
  103. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  104.               virtual ~RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm();
  105.  
  106.  
  107.      Deallocate previously allocated resources.
  108.  
  109.  
  110.  
  111.  
  112.  
  113. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  114.               virtual RWvostream&
  115.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const char* s);
  116.  
  117.  
  118.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the character string starting at ssss
  119.      to the output stream using the XDR format.  The character string is
  120.      expected to be null terminated.
  121.  
  122.               virtual RWvostream&
  123.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(char c);
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                          RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the character cccc to the output
  141.      stream using the XDR format.  Note that c is treated as a character, not
  142.      a number. This member attempts to preserve the symbolic characters values
  143.      transmitted over the stream.
  144.  
  145.               virtual RWvostream&
  146.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(wchar_t wc);
  147.  
  148.  
  149.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the wide character wwwwcccc to the
  150.      output stream using the XDR format.  Note that wwwwcccc is treated as a
  151.      character, not a number.
  152.  
  153.               virtual RWvostream&
  154.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned char c);
  155.  
  156.  
  157.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned character cccc to the
  158.      output stream using the XDR format.  Note that cccc is treated as a
  159.      character, not a number.
  160.  
  161.               virtual RWvostream&
  162.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(double d);
  163.  
  164.  
  165.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the ddddoooouuuubbbblllleeee dddd to the output stream
  166.      using the XDR format.
  167.  
  168.               virtual RWvostream&
  169.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(float f);
  170.  
  171.  
  172.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the ffffllllooooaaaatttt ffff to the output stream
  173.      using the XDR format.
  174.  
  175.               virtual RWvostream&
  176.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(int i);
  177.  
  178.  
  179.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the integer iiii to the output stream
  180.      using the XDR format.
  181.  
  182.               virtual RWvostream&
  183.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned int i);
  184.  
  185.  
  186.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned integer iiii to the
  187.      output stream using the XDR format.
  188.  
  189.               virtual RWvostream&
  190.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(long l);
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                          RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the lllloooonnnngggg llll to the output stream
  207.      using the XDR format.
  208.  
  209.               virtual RWvostream&
  210.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned long l);
  211.  
  212.  
  213.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned lllloooonnnngggg llll to the output
  214.      stream using the XDR format.
  215.  
  216.               virtual RWvostream&
  217.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(short s);
  218.  
  219.  
  220.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the sssshhhhoooorrrrtttt ssss to the output stream
  221.      using the XDR format.
  222.  
  223.               virtual RWvostream&
  224.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<((((unsigned short );
  225.  
  226.  
  227.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned sssshhhhoooorrrrtttt ssss to the output
  228.      stream using the XDR format.
  229.  
  230.               virtual RWvostream&
  231.           ppppuuuutttt(char c);
  232.  
  233.  
  234.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the character cccc to the output
  235.      stream using the XDR format. If the operation fails, it sets the failbit.
  236.      This member only preserves ASCII numerical codes, not the coresponding
  237.      character symbol.
  238.  
  239.               virtual RWvostream&
  240.           ppppuuuutttt(unsigned char c);
  241.  
  242.  
  243.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned character cccc to the
  244.      output stream using the XDR format. If the operation fails, it sets the
  245.      failbit.
  246.  
  247.               virtual RWvostream&
  248.           ppppuuuutttt(wchar_t wc);
  249.  
  250.  
  251.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the wide character wwwwcccc to the
  252.      output stream using the XDR format. If the operation fails, it sets the
  253.      failbit.
  254.  
  255.               virtual RWvostream&
  256.           ppppuuuutttt(const char* p, size_t N);
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                          RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN characters
  273.      starting at pppp to the output stream using the XDR format. If the operation
  274.      fails, it sets the failbit.
  275.  
  276.               virtual RWvostream&
  277.           ppppuuuutttt(const wchar_t* p, size_t N);
  278.  
  279.  
  280.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN wide characters
  281.      starting at pppp to the output stream using the XDR format. If the operation
  282.      fails, it sets the failbit.
  283.  
  284.               virtual RWvostream&
  285.           ppppuuuutttt(const short* p, size_t N);
  286.  
  287.  
  288.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN sssshhhhoooorrrrtttts starting at
  289.      pppp to the output stream using the XDR format. If the operation fails, it
  290.      sets the failbit.
  291.  
  292.               virtual RWvostream&
  293.           ppppuuuutttt(const unsigned short* p, size_t N);
  294.  
  295.  
  296.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN unsigned sssshhhhoooorrrrtttts
  297.      starting at pppp to the output stream using the XDR format. If the operation
  298.      fails, it sets the failbit.
  299.  
  300.               virtual RWvostream&
  301.           ppppuuuutttt(const int* p, size_t N);
  302.  
  303.  
  304.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN integers starting
  305.      at pppp to the output stream using the XDR format. If the operation fails,
  306.      it sets the failbit.
  307.  
  308.               virtual RWvostream&
  309.           ppppuuuutttt(const unsigned int* p, size_t N);
  310.  
  311.  
  312.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN unsigned integers
  313.      starting at pppp to the output stream using the XDR format. If the operation
  314.      fails, it sets the failbit.
  315.  
  316.               virtual RWvostream&
  317.           ppppuuuutttt(const long* p, size_t N);
  318.  
  319.  
  320.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN lllloooonnnnggggs starting at
  321.      pppp to the output stream using the XDR format.  If the operation fails, it
  322.      sets the failbit.
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                          RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.               virtual RWvostream&
  339.           ppppuuuutttt(const unsigned long* p, size_t N);
  340.  
  341.  
  342.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN unsigned lllloooonnnnggggs
  343.      starting at pppp to the output stream using the XDR format. If the operation
  344.      fails, it sets the failbit.
  345.  
  346.               virtual RWvostream&
  347.           ppppuuuutttt(const float* p, size_t N);
  348.  
  349.  
  350.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN ffffllllooooaaaatttts starting at
  351.      pppp to the output stream using the XDR format.  If the operation fails, it
  352.      sets the failbit.
  353.  
  354.               virtual RWvostream&
  355.           ppppuuuutttt(const double* p, size_t N);
  356.  
  357.  
  358.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN ddddoooouuuubbbblllleeees starting
  359.      at pppp to the output stream using the XDR format.  If the operation fails,
  360.      it sets the failbit.
  361.  
  362.               Virtual RWXDRostream&
  363.           fffflllluuuusssshhhh();
  364.  
  365.  
  366.      Send the contents of the stream buffer to output immediately.
  367.  
  368.               Virtual RWXDRostream&
  369.           ppppuuuuttttSSSSttttrrrriiiinnnngggg(const char*s, size_t N);
  370.  
  371.  
  372.      Store the character string for retrieval by RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm::::::::ggggeeeettttSSSSttttrrrriiiinnnngggg.
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.